<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
<style type="text/css">
.panel-title a{display: block;}
</style>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t " id="signupForm"
			method="post" enctype="multipart/form-data">
			<div class="form-group">
				<label class="col-sm-3 control-label">手机号码：</label>
				<div class="col-sm-8">
				<input type="hidden" name="id" value="${cellphones.id }"/>
					<input type="text" class="form-control" id="cellphone"
						name="cellphone" value="${cellphones.cellphone }"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">所属分类：</label>
				<div class="col-sm-8">
				<select class="form-control"  id="type" name="type" >
					<option value="">==请选择==</option>
					<c:forEach items="${fns:getDictList('cellphone_type')}" var="tclassify">
					<option value="${tclassify.value }" <c:if test="${tclassify.value  eq cellphones.type}">selected="selected"</c:if>>${tclassify.valueName }</option>
					</c:forEach>
				</select>
				</div>
			</div>
			<div class="form-group" style="display: none;">
				<label class="col-sm-3 control-label">拥有者：</label>
				<div class="col-sm-8">
					<input type="hidden" class="form-control" id="userId" name="userId"  value="${cellphones.userId }"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
				   <textarea rows="2" cols="2" name="remark" placeholder="请输入备注"  class="form-control" >${cellphones.remark }</textarea>
				</div>
			</div>

			<div class="form-group" style="text-align: center;">
				<div class="col-sm-12">
					<button class="btn btn-primary" type="button" id="sub" >提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
    $(function () {
        $("#sub").click(function () {
        	//批量验证表单非空
        	function checkForm(arr){
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
        	  return true;
        	};
        	//调用方式
        	var arr=new Array(
        	  new Array('cellphone','手机号码未填写!'),
        	  new Array('type','所属分类未选择!')
        	);
        	if(!checkForm(arr)){
        	  return false;
        	}
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/cellphone/update',
					type : 'post',
					dataType : "json",
					success : function(data) {
						if (data.code == 200) {
							swal({
								title : data.message,
								type : "success",
								showCancelButton : false,
								confirmButtonText : "确定",
								animation : "slide-from-bottom",
								closeOnConfirm : true
							}, function() {
								top.Dialog.close();
							});
						} else {
							swal("错误", data.message, "error");
						}
					}
				});

			});
		});
    //分配资源
	function openTree(obj){
		 top.jzts();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="请选择";
		 diag.URL = '<%=contextPath %>/'+obj+'/openZtree';
		 diag.Width = 250;
		 diag.Height = 400;
		 diag.CancelEvent = function(){ //关闭事件
			 var tempid = diag.innerFrame.contentWindow.document.getElementById('tempids').value;
			 var tempname = diag.innerFrame.contentWindow.document.getElementById('tempnames').value;
			if(tempid.length!==0){
				$("#"+obj+"Id").val(tempid);
				$("#"+obj+"Name").val(tempname);
			}
			diag.close();
		 };
		 diag.show();
	}
	</script>
</body>
</html>